<template>
  <a-layout>
    <a-layout-sider v-model:collapsed="collapsed" :trigger="null" collapsible>
      <div class="logo">
        <div class="logo_l">
          <img class="login_img" src="../../assets/login.png" />
          <h3 v-if="!collapsed" class="login_title">
            智慧医院管理系统
          </h3>
        </div>
      </div>
      <div class="main_box">
        <a-menu theme="dark" mode="inline" v-model:selectedKeys="selectedKeys" @click="handleClick">
          <!-- <a-menu-item key="appointment">
            <user-outlined />
            <span>预约管理</span>
          </a-menu-item> -->
          <a-sub-menu key="">
            <template #title>
              <span>
                <video-camera-outlined />
                <span>病史管理</span>
              </span>
            </template>
            <a-menu-item key="illness">疾病分类</a-menu-item>
            <a-menu-item key="illnessmsg">病史信息</a-menu-item>
          </a-sub-menu>
          <a-sub-menu key="">
            <template #title>
              <span>
                <video-camera-outlined />
                <span>医院管理</span>
              </span>
            </template>
            <a-menu-item key="admin">科室信息</a-menu-item>
            <a-menu-item key="doctor">医生标签</a-menu-item>
            <a-menu-item key="hospital">医院信息</a-menu-item>
          </a-sub-menu>

          <a-sub-menu key="">
            <template #title>
              <span>
                <video-camera-outlined />
                <span>药品信息</span>
              </span>
            </template>
            <a-menu-item key="drug">药品分类</a-menu-item>
            <a-menu-item key="drugmsg">药品列表</a-menu-item>
          </a-sub-menu>
          <a-sub-menu key="">
            <template #title>
              <span>
                <video-camera-outlined />
                <span>文章管理</span>
              </span>
            </template>
            <a-menu-item key="article">文章分类</a-menu-item>
            <a-menu-item key="articlemsg">文章信息</a-menu-item>
          </a-sub-menu>
          <a-sub-menu key="">
            <template #title>
              <span>
                <video-camera-outlined />
                <span>疾病管理</span>
              </span>
            </template>
            <a-menu-item key="illnessmsg">疾病信息</a-menu-item>
            <a-menu-item key="illness">疾病分类</a-menu-item>
          </a-sub-menu>
          <a-sub-menu key="manager">
            <template #title>
              <span>
                <video-camera-outlined />
                <span>管理员信息</span>
              </span>
            </template>
            <a-menu-item key="role">角色信息</a-menu-item>
            <a-menu-item key="juri">权限信息</a-menu-item>
            <a-menu-item key="manage">管理员列表</a-menu-item>
          </a-sub-menu>
          <a-menu-item key="indent">
            <user-outlined />
            <span>订单管理</span>
          </a-menu-item>
          <a-menu-item key="user">
            <user-outlined />
            <span>用户信息</span>
          </a-menu-item>
        </a-menu>
      </div>
    </a-layout-sider>
    <a-layout>
      <a-layout>
        <a-layout-header style="background: #fff; padding: 0">
          <menu-unfold-outlined v-if="collapsed" class="trigger" @click="() => (collapsed = !collapsed)" />
          <menu-fold-outlined v-else class="trigger" @click="() => (collapsed = !collapsed)" />
        </a-layout-header>
        <a-layout-content :style="{
          margin: '24px 16px',
          padding: '24px',
          background: '#fff',
          minHeight: '280px',
        }">
          <router-view></router-view>
        </a-layout-content>
      </a-layout>
    </a-layout>
  </a-layout>
</template>
<script>
import {
  UserOutlined,
  VideoCameraOutlined,
  UploadOutlined,
  MenuUnfoldOutlined,
  MenuFoldOutlined,
} from "@ant-design/icons-vue";
import { defineComponent, ref } from "vue";
import { useRouter, useRoute } from "vue-router";
export default defineComponent({
  components: {
    UserOutlined,
    VideoCameraOutlined,
    UploadOutlined,
    MenuUnfoldOutlined,
    MenuFoldOutlined,
  },
  setup() {
    const router = useRouter();
    const route = useRoute();
    const selectedKeys = ref(["/"]);
    if (Boolean(location.href.split("/").pop())) {
      selectedKeys.value = [location.href.split("/").pop()];
    }
    const handleClick = (e) => {
      console.log(e.key);
      router.push({ name: e.key });
    };
    return {
      selectedKeys,
      collapsed: ref(false),
      handleClick,
    };
  },
});
</script>
<style>
:where(.css-dev-only-do-not-override-185kyl0).ant-layout.ant-layout-has-sider {
  height: 100vh;
}

#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}

#components-layout-demo-custom-trigger .logo {
  height: 42px;
  background: rgba(255, 255, 255, 0.3);
  margin: 16px;
}

.logo_l {
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.logo {
  height: 8%;
}

::-webkit-scrollbar {
  display: none;
  /* Chrome Safari */
}

.main_box {
  height: 90%;
  scrollbar-width: none;
  /* firefox */
  -ms-overflow-style: none;
  /* IE 10+ */
  overflow-x: hidden;
  overflow-y: auto;
}

.login_img {
  height: 40px;
  width: 40px;
  border-radius: 100%;
  box-sizing: border-box;
}

.login_title {
  color: #fff;
}

.site-layout .site-layout-background {
  background: #fff;
}
</style>
